package com.xingdata.jjxc.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xingdata.jjxc.R;
import com.xingdata.jjxc.enty.NaviHistoryEntity;

/**
 * @what 高德兴趣点搜索listView adapter
 * @author ysc
 * @date 2016-08-23
 */
public class AddWayPointsListAdapter extends BaseAdapter {
	
	final static String TAG = "AddWayPointsListAdapter";
	
	private ArrayList<NaviHistoryEntity> wayPointsArrayAdapter;
	private Context mContext;
	//添加datatype参数，传参数1显示的是poi搜索历史记录，传0显示添加途经点的视图
	public AddWayPointsListAdapter(ArrayList<NaviHistoryEntity> naviHistoryEntityList, Activity activity) {
		this.mContext=activity;
		this.wayPointsArrayAdapter=naviHistoryEntityList;
	}

	@Override
	public int getCount() {
		return wayPointsArrayAdapter.size();
	}

	@Override
	public Object getItem(int position) {
		return wayPointsArrayAdapter.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(mContext).inflate(R.layout.addwaypoints_listview_item, null);
			holder.address_title = (TextView) convertView.findViewById(R.id.waypoints_address_title);
			holder.address = (TextView) convertView.findViewById(R.id.waypoints_address);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		 
		holder.address_title.setText(wayPointsArrayAdapter.get(position).getloca_nickname());
//		Log.d(TAG, "地名："+naviHistoryEntityList.get(position).getloca_nickname());
		
		holder.address.setText(wayPointsArrayAdapter.get(position).getloca_address());
//		Log.d(TAG, "地址："+naviHistoryEntityList.get(position).getloca_address());
		return convertView;
	}
	
	private class ViewHolder {
		TextView address_title;
		TextView address;
	}

}
